#pragma once

#include <gofcl_dac_dh_r.h>

// 该寄存器的单个部分。由于存在由两个单体摞成的寄存器、共4字节，因此用此定义。
typedef struct {
	u16_s : 4;
	u16_s DH : 12;
} dac_l12dh_mono_s;

_Static_assert(sizeof(dac_l12dh_mono_s) == 2,
	       "Struct dac_l12dh_mono_s defined error!");

typedef struct {
	dac_l12dh_mono_s l12dh_mono;
	u32_s : 16;
} dac_l12dh_s;

_Static_assert(sizeof(dac_l12dh_s) == 4, "Struct dac_l12dh_s defined error!");

static inline void dac_wreg_l12dh_s(dac_dh_re dac_dh_r, dac_l12dh_s l12dh) {
	union {
		dac_l12dh_s l;
		u32_s u;
	} lu = {
		.l = l12dh,
	};
	dac_wreg_dh(dac_dh_r, DAC_DH_L12DH_RR, lu.u);
}
